# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=ike-scan
pkgver=1.9.5
pkgrel=3
pkgdesc='A tool that uses IKE protocol to discover, fingerprint and test IPSec VPN servers.'
arch=('x86_64' 'aarch64')
groups=('blackarch' 'blackarch-scanner')
url='http://www.nta-monitor.com/tools/ike-scan/'
license=('GPL')
depends=('openssl')
makedepends=('make' 'gcc')
source=("https://github.com/royhills/ike-scan/archive/refs/tags/$pkgver.tar.gz"
        '0001-Use-zu-instead-of-u-printf-format-for-size_t.patch'
        '0002-Use-printf-ld-format-for-timeval-tv_usec-field.patch'
        '0003-acinclude.m4-fix-Wimplicit-int-errors-Clang-16-compa.patch'
        '0004-acinclude.m4-fix-typo-in-x-if-check.patch'
        '0005-configure.ac-Fix-recognising-Wformat-security-with-C.patch'
        '0006-Removed-obsolete-autoconf-macros.-Incremented-versio.patch'
        'acinclude.m4-Fix-Werror-implicit-function-declaration.patch'
        'disable_aggressive_in_v2.patch'
        'skip-malformed-comp.patch')
sha512sums=('5eb98e41c639bc30996041f4e759a6ada7f4baa5b8102992ac2313ed8ff51032d877b116bc24972e0ecd652290849aa67a63523d92ee63af6577112350ee5590'
            '3e5a6b2172ed7ff486043fdb13a38c5200a4da44a8b2583fba2a30e22b48f77e0040dcc3f19ea50e9171f709812410891bd1fa9311f4177fe68e574cf6bde54a'
            '40ff1841916b9e92d2276276a13b7a04bba55661eb72948542bce1f3fb997f80b29ca1a588da9bd5710450c1bc9e4f3733d7f45bab9253779857464c17052a41'
            'd85fa152b193460e3d3ab9d46784979953877082f21ab30f414a152d575d25151bfdd8fef4a1683c7741403960be25705bda7ba472933858eb9af5e5f97ec62d'
            'ac9674378ab27770b2ccb1f7247717fde904d1d2deeabe8b3724326acc84c1e08f4aee27c23b1c836b04693628c76bc780f0197d18a43586f3080315aa99fd3b'
            '6607e3e6849290a54aa6467218a0395efeb6c17a4642bbbbe1155eb515246e13a46d55af96b6a1d9fc5a29b4489c87ef4be83a160da09ad007a2b5cf16090eae'
            'cd32ed9649c3d455bb9f6f1f4984e7b1ba2fc71383947db23b73f86abb1cadb68ab09e9ebeb2b38b6c157a7dc392cf198b1bbe9b1efc42f57e285cf3c3bb7362'
            '45a5571b08fff3a34df0dc41fc5093c4f43235acbfd207b9681c7716ff434538908c294d11bffcb8059330c75a02afca1d979eb8f4d74872201facc8cd15934e'
            'd9f8d1838bd57578321879a7ffd87c167494d6097e7bf0f53ae249c682810b65184e39fc60ba78fbf0b18117a56892da4a427c5eefdb9f7e3d0534a6dc2c589c'
            '60f6af7f014a26de684db06658af680ed50f82e82d9c511157669b1d0690cc45a81af408fa745cbfd200b1b98785988cb7f22d5d8458b258653a23e1c1ed928b')

prepare() {
  cd "$pkgname-$pkgver"

  patch -p1 < ../0001-Use-zu-instead-of-u-printf-format-for-size_t.patch
  patch -p1 < ../0002-Use-printf-ld-format-for-timeval-tv_usec-field.patch
  patch -p1 < ../0003-acinclude.m4-fix-Wimplicit-int-errors-Clang-16-compa.patch
  patch -p1 < ../0004-acinclude.m4-fix-typo-in-x-if-check.patch
  patch -p1 < ../0005-configure.ac-Fix-recognising-Wformat-security-with-C.patch
  patch -p1 < ../0006-Removed-obsolete-autoconf-macros.-Incremented-versio.patch
  patch -p1 < ../acinclude.m4-Fix-Werror-implicit-function-declaration.patch
  patch -p1 < ../disable_aggressive_in_v2.patch
  patch -p1 < ../skip-malformed-comp.patch

  aclocal
  autoheader
  automake --add-missing
  autoconf
}

build() {
  cd "$pkgname-$pkgver"

  if [[ "$CARCH" == "x86_64" ]]; then
    ./configure --prefix=/usr --mandir=/usr/share/man --with-openssl
  else
    ./configure --prefix=/usr --mandir=/usr/share/man --with-openssl \
      --build=arm
  fi
}

package() {
  cd "$pkgname-$pkgver"

  make DESTDIR="$pkgdir" install
}

